package lines.gameengine;

import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;

/**
 * @author vpotapenko
 */
public class FieldPointTest {

    private static final int X = 25;
    private static final int Y = 98;

    private FieldPoint point;
    private static final int ANOTHER_X = 10;
    private static final int ANOTHER_Y = 5;

    @Before public void setUp() {
        point = new FieldPoint(X, Y);
    }

    @Test public void shouldInitializeCoordinates() {
        assertThat(point.getX(), equalTo(X));
        assertThat(point.getY(), equalTo(Y));
    }

    @Test public void shouldNotEqualByCoordinatesOrToNull() {
        FieldPoint anotherPoint = new FieldPoint(ANOTHER_X, ANOTHER_Y);
        assertThat(point.equals(anotherPoint), equalTo(false));

        assertThat(point.equals(null), equalTo(false));
    }

    @Test public void shouldEqualByCoordinates() {
        FieldPoint anotherPoint = new FieldPoint(X, Y);

        assertThat(point.equals(anotherPoint), equalTo(true));
        assertThat(anotherPoint.equals(point), equalTo(true));

        assertThat(point, not(sameInstance(anotherPoint)));
    }
}
